package com.util.vmwareops;
import java.sql.Connection;
import java.sql.SQLException;

import java.sql.Statement;

public class InsertVCenter {
    public static void main(String [] args) throws InterruptedException {
        //Date time = new Date();
        //DateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //f.format(time)
        DBConnectionPool dbPool = DBConnectionPoolFactory.getDBConnectionPool("vmwareops");

        Connection con = dbPool.getConnection();
        String[] sqls = new String[]{
                String.format(
                    "insert into resource_bundle_vc values(\"%s\", \"%s\", %s, %s, \"%s\", %d, \"%s\", \"%s\")",
                    MyUtils.getUUID("VCenter"),
                    "zjquststvc03.bocvmware.com",
                    "sysdate()",
                    "sysdate()",
                    "182.242.100.10",
                    443,
                    "administrator@vsphere.local",
                    "VMware123!"
                ),
                String.format(
                        "insert into resource_bundle_vc values(\"%s\", \"%s\", %s, %s, \"%s\", %d, \"%s\", \"%s\")",
                        MyUtils.getUUID("VCenter"),
                        "zjtestvcsa01.bocomdsk.com",
                        "sysdate()",
                        "sysdate()",
                        "182.242.8.11",
                        443,
                        "administrator@vsphere.local",
                        "VMware123!"
                ),
        };
        //
        Statement stmt = null;
        try {
            stmt = con.createStatement();
            for(String sql : sqls) {
                System.out.println(sql);
                stmt.execute(sql);
            }
            if(stmt!=null) {
                stmt.close();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbPool.closeAll();
        }
    }
}
